<?
require_once('../mod_config.php');
$moduol_name = 'Phân quyền';
$array_mod = array();
$db = new DB();
$sql =  "SELECT mod_id as id,
            mod_name as fullname,
            mod_active as status
         FROM
            modules
         ORDER BY
            mod_order DESC
         ";
$array_mod = $db->query($sql);
class author{
   
   public $id = -1;
   public $list_permisstion = array();
   public $name = 'Unknow';
   
   /**
    * 
    * The constructor
   */
   public function __construct($id){
      if($id > 0){
         $this->id = $id;
         $str_access = "SELECT 
                              modules.mod_id,
                              modules.mod_name
                           FROM
                              modules
                           INNER JOIN
                              author
                           ON
                              modules.mod_id = author.mod_id
                           WHERE
                              adt_id = " . $id;
         $db = new DB();
         $this->list_permisstion = $db ->query($str_access);
         
         $str_access = "SELECT   adt_id,
                                 adt_username,
                                 adt_status
                              FROM
                                 administrator
                              WHERE
                                 adt_id = " . $id;
         $row = $db->row($str_access);    
         $this->name = $row['adt_username'];     
      }
   }
   
   /**
    * Add author to admin page
   */
   public static function addAuthor(){
      
   }
   /**
    * 
    * get list author
   */
   public static function getListAuthor(){
      $array_adt = array();
      $str_access = "SELECT 
                        adt_id as id,
                        adt_username as name,
                        adt_status as active	
                     FROM  
                        administrator";
      $db = new DB();
      $array_adt = $db->query($str_access);
      return $array_adt; 
   }
   
   /**
    * 
    * get list author
   */
   public static function getListPermisstion(){
      $array_permission = array();
      $str_access = "SELECT 
                        modules.mod_id,
                        modules.mod_name
                     FROM
                        modules";
      $db = new DB();
      $array_permission = $db->query($str_access);      
      return $array_permission; 
   }
}
?>